package com.jdbc.dbutils.crud;

import com.jdbc.entity.Student;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author wzm
 * @create 2023-02-23 15:42
 */
public class CustomHandler implements ResultSetHandler<Student> {
    @Override
    public Student handle(ResultSet resultSet) throws SQLException {
        if(resultSet.next()){
            int id = resultSet.getInt("id");
            String stu_name = resultSet.getString("stu_name");
            String stu_sex = resultSet.getString("stu_sex");
            int age = resultSet.getInt("age");
            String address = resultSet.getString("address");
            int status = resultSet.getInt("status");
            return new Student(id,stu_name,stu_sex,age,address,status);
        }
        return null;
    }
}
